import {defineComponent, onMounted, onUnmounted, reactive} from 'vue'
import Draw from './draw'
import {useWebSocketStore} from "@/store/websocket";
import {computed} from "vue";
import {useStore} from "vuex";
export default defineComponent({
  components: {
    Draw
  },
  setup() {
    const wsStore = useWebSocketStore()
    const store = useStore()
    const strategy = computed(() => store.getters.currentStrategy) // 策略列表
    // 直接从store中获取响应式数据
    const cdata = computed(() => ({
      hours: wsStore.cdata[strategy.value].hours,
      batteryEnergy: wsStore.cdata[strategy.value].batteryEnergy,
      chargeStatus: wsStore.cdata[strategy.value].chargeStatus,
      totalEnergy: wsStore.totalEnergy
    }))
    // onMounted(()=>{
    //
    // })
    // onUnmounted(() => {
    //
    // })
    return () => {
      return <div>
        <Draw cdata={cdata.value} />
      </div>
    }
  }
})